$(document).ready(function(){
    $("#friend-btn").click(function(){
        var id = $(this).data().id;
        $.post("/api/friend/add", {id: id}, function(res){
            if(res.code == "1001"){
                return window.location.href = "/user/login?next=" + window.location.pathname;
            };
            if(res.code == "0"){
                $("#friend-btn").attr("disabled", true);
            };
        }, "json");
    });
});